#include "../Hdr/Input.h"

Eternal::Core::InputManager::InputManager()
{
	mX = mY = 0;
}

Eternal::Core::InputManager::~InputManager()
{
	
}

/* Should be called once per frame to update keyboard buffer */
void Eternal::Core::InputManager::BeginFrame()
{
//	SDL_GetMouseState(&mX, &mY);
	for ( unsigned short int i = 0;i < 256;i++ )
	{
		prevStates[i] = false;
		if ( Keys[i] )
		{
			prevStates[i] = true;
		}
	}
}

int Eternal::Core::InputManager::GetMouseX() const
{
	return mX;
}

int Eternal::Core::InputManager::GetMouseY() const
{
	return mY;
}

/* Key hit, not to be confused with key press */
bool Eternal::Core::InputManager::IsKeyHit(eKey key) const
{
	if ( prevStates[key] )	{
		return false;
	}
	if ( Keys[key] )	{
		return true;
	}
	return false;
}

/* Key press, the key is being held down  */
bool Eternal::Core::InputManager::IsKeyPress(eKey key) const
{
	if ( Keys[key] )	{
		return true;
	}
	return false;
}